import sqlite3

conn = sqlite3.connect('trade_monitor.db')
cursor = conn.cursor()

# 删除旧表
cursor.execute('DROP TABLE IF EXISTS trade_records')

# 创建新表
create_table_sql = '''
CREATE TABLE IF NOT EXISTS trade_records (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    trade_time TEXT NOT NULL,
    product_name TEXT NOT NULL,
    exchange_code TEXT NOT NULL,
    direction TEXT NOT NULL,
    action_type TEXT NOT NULL,
    volume INTEGER NOT NULL,
    price REAL NOT NULL,
    remark TEXT
);
'''
cursor.execute(create_table_sql)
conn.commit()
conn.close()